function newim = implace(im1, im2, roff, coff)

if roff <= 0, 
    roff=1;
end;
if coff <= 0, 
    coff=1;
end;

[im1r, im1c, im1d] = size(im1);
[im2r, im2c, im2d] = size(im2);

cutc = im2c;
if coff + im2c > im1c,
    im2c-((im2c+coff)-im1c);
end

cutr = im2r;
if roff + im2r > im1r,
    im2r-((im2r+roff)-im1r);
end

im1( roff:cutr+roff-1, coff:cutc+coff-1, :) = im2(1:cutr, 1:cutc, :);
newim = im1(1:im1r, 1:im1c, :);




